//index.js
var express=require('express');
var path = require('path');
var bodyParser = require('body-parser')
var index = require('./routes/index');
var api = require('./routes/api');
var expressJwt = require("express-jwt");
var app= express();


app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

app.use(function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With,Authorization");
    res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    next();
});


//配置静态文件夹,在本地public读取css,js,html等文件
app.use(express.static(path.join(__dirname, 'public')));

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');


app.use('/', index);
app.use('/',api);




app.listen("8899");
console.log("run server:http://localhost:8899");